package com.mano.mall.web.gatewayhandler.controller;

import com.alibaba.fastjson.JSONObject;
import com.mano.mall.api.dto.gatewayhandler.input.GatewayHandlerInputDTO;
import com.mano.mall.api.dto.gatewayhandler.output.GatewayHandlerOutputDTO;
import com.mano.mall.common.base.BaseApiService;
import com.mano.mall.common.base.BaseResponse;
import com.mano.mall.common.utils.MyBeanUtils;
import com.mano.mall.web.gatewayhandler.feign.GateWayHandlerServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @description:网关handler配置web
 * @author: zj
 */
@RestController
public class GateWayHandlerController extends BaseApiService {

	@Autowired
	private GateWayHandlerServiceFeign gateWayHandlerServiceFeign;
	/**
	 * 添加网关handler
	 * @return
	 */
	@RequestMapping("/addGWHandler")
	public BaseResponse addGWHandler(GatewayHandlerInputDTO gatewayHandlerInputDTO) {
	    gateWayHandlerServiceFeign.addGWHandler(gatewayHandlerInputDTO);
	    return setResultSuccess();
	}

    /**
     * 删除网关handler
     * @param id
     * @return
     */
    @RequestMapping("/deleteGWHandler")
    public BaseResponse deleteGWHandler(Integer id) {
        gateWayHandlerServiceFeign.deleteGWHandler(id);
        return setResultSuccess();
    }

    /**
     * 开启网关handler
     * @param id
     * @return
     */
    @RequestMapping("/openGWHandler")
    public BaseResponse openGWHandler(Integer id) {
        gateWayHandlerServiceFeign.openGWHandler(id);
        return setResultSuccess();
    }

    /**
     * 关闭网关handler
     * @param id
     * @return
     */
    @RequestMapping("/closeGWHandler")
    public BaseResponse closeGWHandler(Integer id) {
        gateWayHandlerServiceFeign.closeGWHandler(id);
        return setResultSuccess();
    }

    /**
     *  上移
     * @param id
     * @return
     */
    @RequestMapping("/upGWHandler")
    public BaseResponse upGWHandler(Integer id) {
        gateWayHandlerServiceFeign.upGWHandler(id);
        return setResultSuccess();
    }

    /**
     * 下移
     * @param id
     * @return
     */
    @RequestMapping("/downGWHandler")
    public BaseResponse downGWHandler(Integer id) {
        gateWayHandlerServiceFeign.downGWHandler(id);
        return setResultSuccess();
    }

    /**
     * 网关handler 列表
     * @return
     */
    @RequestMapping("/getGWHandlerList")
    public BaseResponse getGWHandlerList() {
        BaseResponse<List<GatewayHandlerOutputDTO>> gwHandlerList = gateWayHandlerServiceFeign.getGWHandlerList();
        return gwHandlerList;
    }
}
